<!-- 兰文杰 currentDate-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>网盘注册</title>
<%@include file="include/css.jsp"%>
<style type="text/css">
	.desc{
		font-size:10px;
	}
</style>
</head>
<body>
	<nav class="navbar navbar-expand-lg navbar-light"
		style="background-color: #e3f2fd;">
		<a class="navbar-brand" href="#">网盘</a>
		<button class="navbar-toggler" type="button" data-toggle="collapse"
			data-target="#navbar" aria-controls="navbar" aria-expanded="false"
			aria-label="Toggle navigation">
			<span class="navbar-toggler-icon"></span>
		</button>
		<div class="collapse navbar-collapse" id="navbar">
			<ul class="navbar-nav ml-auto">
				<li class="nav-item"><a class="nav-link"
					href="${pageContext.request.contextPath}/login">登录</a></li>
			</ul>
		</div>
	</nav>
	<br />
	<div class="container">
		<div class="row">
			<div class="col-md-8">
				<h3>注册</h3>
				<div class="card">
					<div class="card-body">
						<form>
							<div class="form-group input-group-sm">
								<label for="user-email">电子邮件地址&nbsp;<span class="text-danger">*</span></label> <input
									type="email" class="form-control" id="user-email"
									aria-describedby="emailHelp"> <small id="emailHelp"
									class="form-text text-muted">例如：272048417@QQ.com</small>
							</div>
							<div class="form-group input-group-sm">
								<label for="user-name">真实姓名&nbsp;<span class="text-danger">*</span></label> <input
									type="text" class="form-control" id="user-name">
							</div>
							<div class="form-group input-group-sm">
								<label for="user-loginname">用户名&nbsp;<span class="text-danger">*</span></label> <input
									type="text" class="form-control" id="user-login-name">
							</div>
							<div class="form-group input-group-sm">
								<label for="user-password">密码&nbsp;<span class="text-danger">*</span></label> <input
									type="password" class="form-control" id="user-password">
							</div>
							<button type="button" class="btn btn-primary btn-block" id="create-account-button">创建账号</button>
						</form>
					</div>
				</div>
			</div>
			<div class="col-md-4">
				<p class="">
					如果您已经有云存储账号，请直接&nbsp;&nbsp;<a
						href="${pageContext.request.contextPath}/login">登录</a>
				</p>
				<p class="font-weight-bold">云存储平台是为谁服务的？</p>
				<p class="desc">云存储平台面向任何希望使用云存储的用户，这些用户通常是院系教师、助教及教学技术小组。</p>

				<p class="font-weight-bold">在云存储平台创建需要掌握哪些技术？</p>
				<p class="desc">对几乎所有熟悉云网盘（例如百度云，360网盘）的人而言，云存储平台都是很容易使用的。当然我们会一如既往地为您提供帮助，不要犹豫赶快加入吧。</p>
			</div>
		</div>
		<div class="row" style="margin-top: 10px;">
			<div class="col-md-8">
				Copyright &copy;&nbsp;2020&nbsp;TLF工作室
			</div>
			<div class="col-md-4 text-right">
				服务条款&nbsp;&nbsp;&nbsp;隐私政策
			</div>
		</div>
	</div>
	<%@include file="include/js.jsp"%>
	<script type="text/javascript">
	$(function() {
		$("#create-account-button").click(function() {
			v = $("#user-email").val();
			if (v == "") {
				alert("请输入用户电子邮箱！");
				return;
			} 
			v = $("#user-name").val();
			if (v == "") {
				alert("请输入用户真实姓名！");
				return;
			} 
			v = $("#user-login-name").val();
			if (v == "") {
				alert("请输入用户名！");
				return;
			} 
			v = $("#user-password").val();
			if (v == "") {
				alert("请输入密码！");
				return;
			} 
			$.ajax({
				url : "${pageContext.request.contextPath}/user/register/save",
				type : "POST",
				data : {
					name:$("#user-name").val(),
					loginName:$("#user-login-name").val(),
					password:$("#user-password").val(),
					email:$("#user-email").val()
				},
				dataType : "json",
				success : function(result) {
					if (result.code === 0) {
						window.location.href="${pageContext.request.contextPath}/main";
					} else {
						alert(result.message);
					}
				},
				error : function(err) {
					alert("网络请求操作失败！");
					console.log(err);
				}
			});
		});
	});
	</script>
</body>
</html>